package com.xhgd.order.controller;

import com.xhgd.order.bean.Order;


import com.xhgd.order.properties.OrderProperties;
import com.xhgd.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
//@RefreshScope
@RestController
public class OrderController {
    @Autowired
    OrderService orderService;
    @Autowired
    OrderProperties orderProperties;

    @GetMapping("/config")
    public String config(){
        return "timeout:"+orderProperties.getTimeout()+":   auto-confirm:"+orderProperties.getAutoConfirm();


    }


    @GetMapping("/create")
    // 创建订单,并返回订单
    public Order createOrder(@RequestParam("productId") Long productId,
                             @RequestParam("userId") Long userId) {
        Order order = orderService.createOrder(productId, userId);

        return order;


    }
}
